package Server

import (
	"log"
	"strings"
)

type IAuthInterface interface {
	GetAuthInfo(token string, url string) (err error, headers map[string]string)
	InitWithConfig(config map[string]string)
}

type AuthFactory struct {
}

var auth_factory_instance AuthFactory

func init() {
	auth_factory_instance = AuthFactory{}
}

func GetAuthFactoryInstance() *AuthFactory {
	return &auth_factory_instance
}

func (this *AuthFactory) CreateAuthInstance(t string) IAuthInterface {
	if strings.ToLower(t) == "bearer" {
		return &BeareAuth{}
	}

	if strings.ToLower(t) == "bearerconfig" {
		return &BearerConfigAuth{}
	}

	log.Fatalf("%s 是不支持的类型 \r\n", t)
	return nil
}
